package com.carlos.company.demo;

import com.carlos.company.pojo.Company;
import org.apache.commons.collections4.ListUtils;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

/**
 * 不可变 List
 *
 * @author 李健成
 * @date 2021/10/20
 */

public class Unmodifiable {

    public static void main(String[] args) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, NoSuchFieldException {

        Company company = new Company();
        Class<? extends Company> companyClass = company.getClass();
        Company instance = companyClass.newInstance();
        Constructor<? extends Company> constructor = companyClass.getConstructor(Long.class, String.class, LocalDateTime.class);
        Field companyName = companyClass.getDeclaredField("companyName");
        Method toString = companyClass.getMethod("toString");
        System.out.println("下面是反射出的 toString 方法");
        System.out.println(toString.invoke(instance));
    }

}
